from peewee import MySQLDatabase
from playhouse.shortcuts import RetryOperationalError

from frame.config import Config


class MyRetryDB(RetryOperationalError, MySQLDatabase):
    pass


db = MyRetryDB(Config.MYSQL_DB_NAME,
               host=Config.MYSQL_DB_HOST,
               port=Config.MYSQL_DB_PORT,
               user=Config.MYSQL_DB_USER,
               passwd=Config.MYSQL_DB_PWD,
               use_unicode=True,
               charset='utf8')

db.connect()
